package com.example.administrator.systemfailreport.adapter;

import android.content.Context;
import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentPagerAdapter;

import com.example.administrator.systemfailreport.activity.MisoperationFragment;
import com.example.administrator.systemfailreport.activity.SysErrorFragment;

/**
 * Created by Administrator on 2017/2/16.
 */
public class FaultRecordAdapter extends FragmentPagerAdapter{
    Context context=null;
    final int PAGE_COUNT=2;
    final String[] titles={"系统故障","误操作"};
    String userId=null;
    public FaultRecordAdapter(FragmentManager fm) {
        super(fm);
    }
    public FaultRecordAdapter(FragmentManager fm,String userId){
        super(fm);
        this.userId=userId;
    }

    @Override
    public Fragment getItem(int position) {
        Fragment fra=null;
        switch (position){
            case 0:
                fra=new SysErrorFragment();
                Bundle bundle=new Bundle();
                bundle.putString("userId",userId);
                fra.setArguments(bundle);
                break;
            case 1:
                fra=new MisoperationFragment();
                Bundle bundle1=new Bundle();
                bundle1.putString("userId",userId);
                fra.setArguments(bundle1);
                break;
        }
        return fra;
    }

    @Override
    public int getCount() {
        return PAGE_COUNT;
    }

    @Override
    public CharSequence getPageTitle(int position) {
        return titles[position];
    }
}
